After using TanStack Router in production for eight months, this author believes in organizing code into vertical modules, using loaders for page-level data and suspense queries for component-specific data, and avoiding premature code generalization. He promotes a “go gardening approach” that involves abstracting code only when clear patterns show up.
TanStack Router's Server Functions allows developers to execute code only on the server, keeping sensitive logic away from the client. They are defined using `createServerFn` and can be called from anywhere in the application, including loaders, hooks, and other server functions. Server functions accept a single parameter and also provide access to server request context, allowing developers to work with headers, sessions, and cookies.
TanStack Router, a type-safe routing library for TypeScript, made performance improvements to address a bottleneck in TypeScript's language service when handling large route trees. The issue stemmed from the language service having to infer types for the entire route tree, even when only a specific route was referenced. To solve this, TanStack Router introduced a new approach for file-based routing where the route tree is explicitly declared instead of inferred, allowing the language service to infer types only for the relevant route.